<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	
	$value = array(
		'id_user'				=> "",
		'nama'					=> "",
		'jabatan'				=> "",
		'email'					=> "",
		'username'				=> "",
		'role'					=> "",
		'id_sekolah'			=> "",
		'legend'				=> "Form Input User",
		'info'					=> "Form pendaftaran user",
		'act_form'				=> "user_man/input_user/"
	);
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($user_man->result() as $row){
			$value['id_user'] = $row->ID_USER;
			$value['nama'] = $row->NAMA;
			$value['jabatan'] = $row->JABATAN;
			$value['id_sekolah'] = $row->ID_SEKOLAH;
			$value['email'] = $row->EMAIL;
			$value['username'] = $row->USERNAME;
			$value['role'] = $row->IDROLE;
		}
		$value['legend'] = "Form Edit User";
		$value['info'] = "Form edit data pendaftaran user";
		$value['act_form'] = "user_man/edit_user/".$value['id_user'];
	}//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_user_man"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url('user_man'),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke daftar user','Menampilkan halaman Daftar User'); ?>
	</div>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>

        <li>
		<label class="desc">Jabatan</label>
		<div>
			<input class="field text large" type="text" maxlength="100" size="3" name="jabatan" value="<? if(set_value('jabatan')!='') echo set_value('jabatan'); else echo $value['jabatan'];?>"/> 
		</div>
		<p class="instruct">
			Masukkan Jabatan Pada Kolom ini.			
		</p>
	</li>
<?php if($this->session->userdata('roleid')=='0' && $value["role"] != '0'){ //diknas ?>
        <li>
		<label class="desc">Nama Sekolah *</label>
		    <div>
			    <? 
			    //list unit organisasi
						    $options_unit['0'] = "-- Pilih Nama Sekolah --";
						    foreach($unitoptions->result() as $unit){
							    $options_unit[$unit->ID_SEKOLAH] = $unit->NAMA_SEKOLAH;
						    }
							    echo form_dropdown('id_sekolah',$options_unit,$value["id_sekolah"],'class="chzn-select"');	
			    ?>
		    </div>
		<p class="instruct">
			Pilih Nama Sekolah Pada Kolom ini.			
		</p>
	</li>
	<?php echo form_error('id_sekolah'); }?>
		
	<li>
		<label class="desc">Nama Pemangku Jabatan *</label>
		<div>
			<input class="field text large" type="text" maxlength="100" size="3" name="nama" value="<? if(set_value('nama')!='') echo set_value('nama'); else echo $value['nama'];?>"/> 
		</div>
		<p class="instruct">
			Masukkan Nama Pada Kolom ini.			
		</p>
	</li>
	<?php echo form_error('nama'); ?>			
	<?php if ($value["role"] != '0'){?>	
		<li>
		<label class="desc">Nama Role *</label>
		    <div>
			    <? 
			    //list role
						    $options_role['0'] = "-- Pilih Nama Role --";
						    foreach($roleoptions->result() as $role){
							    $options_role[$role->IDROLE] = $role->NAMA_ROLE;
						    }
							    echo form_dropdown('idrole',$options_role,$value["role"],'class="chzn-select"');	
			    ?>
		    </div>
		<p class="instruct">
			Pilih Nama Role Pada Kolom ini.			
		</p>
	</li>
	<?php echo form_error('idrole'); ?>
	<?}?>
        <li>
			<label class="desc">Email *</label>
			<div>
				<input class="field text medium" type="text" maxlength="100" size="3" name="email" value="<? if(set_value('email')!='') echo set_value('email'); else echo $value['email'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Email Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('email'); ?>
        
        <li>
		<label class="desc">Username *</label>
		<div>
			<input class="field text medium" type="text" maxlength="100" size="3" name="username" value="<? if(set_value('username')!='') echo set_value('username'); else echo $value['username'];?>"/> 
		</div>
		<p class="instruct">
			Masukkan Username Pada Kolom ini.			
		</p>
	</li>
	<?php echo form_error('username'); ?>
        
        <li>
		<label class="desc">Password *</label>
		<div>
			<input class="field text medium" type="password" maxlength="100" size="3" name="password" value="<? if(set_value('password')!='') echo set_value('password');?>"/> 
		</div>
		<p class="instruct">
			Masukkan Password Pada Kolom ini.			
		</p>
	</li>
	<?php echo form_error('password'); ?>
	
	<?if ($value["role"] == '0'){
			$newdata2 = array(
						'roleadmin' => '1'
						);
			$this->session->set_userdata($newdata2);
			echo form_hidden('idrole', '0');
			echo form_hidden('id_sekolah', '-1');
	}?>
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>		
<?= form_close(); ?>
</form>
</div><!--container-->